#include "main.h"

using namespace std;

void Main::OnEvent(SDL_Event* Event) {
    CEvent::OnEvent(Event);
}

void Main::OnExit() {
    Running = false;
}

void Main::OnLButtonDown(int mX, int mY) {
    
    int ID  = mX / 200;
    ID = ID + ((mY / 200) * 3);
    
    SetCell(ID, GRID_TYPE_X);
    CurrentPlayer = 1;
    ChangePlayer();
    if(isFree && !GameEnded){
        int AiCell = minimalAI();
        if(AiCell >= 0)SetCell(AiCell, GRID_TYPE_O);
        CurrentPlayer = 0;
        ChangePlayer();
    }
    /*if(CurrentPlayer == 0) {
        SetCell(ID, GRID_TYPE_X);
        CurrentPlayer = 1;
    }else{
        SetCell(ID, GRID_TYPE_O);
        CurrentPlayer = 0;
    }*/
    
}